package com.xcl.service.impl;

import com.xcl.mapper.ArticleMapper;
import com.xcl.pojo.Article;
import com.xcl.pojo.Result;
import com.xcl.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    ArticleMapper articleMapper;

    // 查询所有文章
    @Override
    public List<Article> findArticle(Integer categoryId, String state) {
        return articleMapper.findArticle(categoryId, state);
    }

    //删除数据
    @Override
    public Result deleteId(Integer id) {
        Integer A =  articleMapper.deleteId(id);
        if(A > 0){
            return Result.success();
        }else{
            return Result.error("删除失败");
        }
    }

    @Override
    public Integer addArticle(Article article) {
        return articleMapper.addArticle(article);
    }

    @Override
    public Integer updateArticle(Article article) {
        return articleMapper.updateArticle(article);
    }
}
